class Solution {
public:
    int peakIndexInMountainArray(vector<int>& arr) {
        //二分思路 分析二段性

        int left=1,right=arr.size()-2,ans=-1;
        while(left<=right)
        {
            int mid=(right-left)/2+left;
            if(arr[mid]>arr[mid-1])
            {
                ans=mid;
                left=mid+1;
            }
            else
            {
                //此时落在下降区间 
                //mid-1是峰值
                ans=mid-1;
                right=mid-1;
            }
        }
        return ans;
    }
};